﻿<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8" />
	<title>string-format</title>

	<!-- WinJS references -->
	<link href="//Microsoft.WinJS.2.0/css/ui-dark.css" rel="stylesheet" />
	<script src="//Microsoft.WinJS.2.0/js/base.js"></script>
	<script src="//Microsoft.WinJS.2.0/js/ui.js"></script>

	<link href="string-format.css" rel="stylesheet" />
	<script src="string-format.js"></script>
</head>
<body>
	<div class="description-page fragment">
		<header aria-label="Header content" role="banner">
			<button class="win-backbutton" aria-label="Back" disabled type="button"></button>
			<h1 class="titlearea win-type-ellipsis">
				<span class="pagetitle">String.format prototype</span>
			</h1>
		</header>

		<section aria-label="Main content" role="main">
			<p>
				The WinJS Toolkit extends the <strong>String</strong> type with a <strong>format</strong> function that you can use to avoid string concatenation.
			</p>
			<p>
				The current string must contain {0}, {1}, {2} etc. placeholders that are substituted with the function arguments.
			</p>
			
			<h2>Usage</h2>
			
			<pre>
var one = 1;
var result = 'This is a simple string with {0} placeholder'.format( one );    // The result is 'This is a simple string with 1 placeholder'.
				
var firstName = 'James';
var lastName = 'Plaster';
var fullName = '{0} {1}'.format( firstName, latName );                        // The result is 'James Plaster'.
			</pre>
		</section>
	</div>
</body>
</html>
